<template>
    <div class="generalPageBox">

        <div class="pageContant">


            <!-- 课程详情 -->
            <div class="pageDetail">
                <div class="titleAll ">
                    <div class="public-header">
                        <div class="public-header-ch">课程详情</div>
                        <div class="public-header-en">COURSE&nbsp;&nbsp;DETAILS</div>
                        <div class="public-header-line"></div>
                    </div>
                    <img src="../../static/image/icon-title.png">
                </div>
            </div>
            <div class="meetingRom"><img src="../../static/image/meeting.png">进入大会议房间</div>

            <div :class="{'theCourse':isA,'theCourses':!isA}">
                <div class="theCourseLeft">
                    <h3>课程名称：{{courseName}}</h3>  
                    <div class="block">
                        <span class="classTitle">课程开始时间</span>
                        <el-date-picker class="classday" v-model="sdate" @change="validateData('sdate')" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" :disabled="allInputDisable"></el-date-picker>
                        <el-time-picker class="classtime" @change="validateData('stime')" arrow-contro value-format="HH:mm" format="HH:mm" v-model="stime" placeholder="任意时间点" :disabled="allInputDisable"></el-time-picker>
                    </div>
                    <div class="block">
                        <span class="classTitle">课程结束时间</span>
                        <el-date-picker class="classday" v-model="edate" @change="validateData('endDate')" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="选择日期" :disabled="allInputDisable"></el-date-picker>
                        <el-time-picker class="classtime" v-model="etime" @change="validateData('endTime')" arrow-contro value-format="HH:mm" format="HH:mm" placeholder="任意时间点" :disabled="allInputDisable"></el-time-picker>
                    </div>
                </div>

                <div class="theCourseCen">                     
                    
                    <div class="free">
                        <el-checkbox label="自动运行" name="type" 
                            v-model="runningshow"
                            @click="runningshow=!runningshow" >
                        </el-checkbox>
                        <el-input v-model="autoRunTime" @change="validateData('autoRunTimes')" :disabled="!runningshow"></el-input>
                    </div>
                    <div v-show="runningshow" class="freetime">
                        <div class="block" v-for="(list,index) in courseRoundModels" :key="index">
                            <label class="classTitle"><i class="red">*</i>第{{index+1}}轮</label>
                            <!-- <el-date-picker class="classday" v-model="list.starDate" @change="validateData('')" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="选择日期" :disabled="allInputDisable"></el-date-picker>                    
                                <el-time-picker  
                                class="classtime" arrow-contro v-model="list.startTime" value-format="HH:mm" format="HH:mm"
                                placeholder="任意时间" @change="validateData('')" :disabled="allInputDisable">
                            </el-time-picker> -->
                            <el-date-picker class="classday" v-model="list.roundsdate" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="选择日期" :disabled="allInputDisable"></el-date-picker>
                            <el-time-picker class="classtime" v-model="list.roundsetime" arrow-contro value-format="HH:mm" format="HH:mm" placeholder="任意时间点" :disabled="allInputDisable"></el-time-picker>
                    
                        </div>
                    </div>
                                      
                </div>
                <div class="theCourseright">
                    <div class="courseBtn">
                        <router-link to="home" class="bntc"><img src="../../static/image/icon-eye.png">课程后台</router-link>
                        <span class="bntc" v-if="boxchooseType=='1'" @click="boxchoose(1)" ><img src="../../static/image/icon-edit.png" alt="">编辑详情</span>
                        <span class="bntc" v-else @click="boxchoose(2)" ><img src="../../static/image/icon-edit.png">保存</span>
                    </div>
                </div>


            </div>

            <!-- 队伍列表 -->
            <div class="teamlist">
                <div class="public-header">
                    <p class="public-header-ch">队伍列表</p>
                    <p class="public-header-en">
                        <span class="pageSub">TEAM&nbsp;&nbsp; MEMBER</span>
                    </p>
                    <p class="public-header-line"></p>
                </div>
                <div class="invite">
                    <p>发起邀请</p>
                     <div class="handle">
                        <el-button v-if="changeBtn" @click="editchangeBtn()">更换组别</el-button>
                        <el-button v-if="!changeBtn" @click="editchangeBtn()">保存更换</el-button>
                        <!-- <span v-if="compileType=='1'" @click="compile(1)" ><img src="../../static/image/icon-edit.png">编辑详情</span>
                        <span v-else @click="compile(2)" ><img src="../../static/image/icon-edit.png">保存</span> -->
                        <el-button v-if="editOrSaveBtnShow" @click="editOrSaveHandler()" ><img src="../../static/image/icon-edit.png">编辑详情</el-button>
                        <el-button v-if="!editOrSaveBtnShow" @click="editOrSaveHandler()" ><img src="../../static/image/icon-edit.png">保存</el-button>
                    </div>
                </div>
                <div :class="{'pageMemberAll':isB,'pageMemberAlls':!isB}">
                   
                    <div class="pageMember" v-for="(member,index) in memberAll" :key="index">
                        <div class="memberTitle">
                            <i>{{member.teamName}}</i>
                            <span><img src="../../static/image/meeting.png">进入大会议房间</span>
                            <span :class="{'shows':isAdd,'hide':!isAdd}">添加学员</span>
                            <!-- <span class="shows">添加学员</span> -->
                        </div>
                        <div class="teamCenter">
                            <table class="teamTable">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>姓名</th>
                                        <th>手机号</th>
                                        <th>性别</th>
                                        <th>子公司/部门</th>
                                        <th>职位</th>
                                        <th></th>
                                    </tr>   
                                </thead>
                                <tbody>
                                    <tr class="memberTr" v-for="(memberList,cindex) in member.teamMembersInfoList" :key="cindex" :data-id="index+'-'+cindex" :draggable="editOrSaveBtnShow" @dragstart="onDragstart($event)" @dragend="onDragend($event)" @dragover="onDragover($event)" @drop="onDrop($event)">
                                        <td>学员{{cindex+1}}</td>
                                        <td><input class="isReadOnly" type="text" v-model="memberList.name" disabled="true"></td>
                                        <td>
                                            <input class="isReadOnly" type="text" v-model="memberList.mobile" @blur="blurValidator(memberList.mobile,memberAll,$event)" disabled="true">
                                            <div class="emptyTip3" v-show="memberList.errorinputtext">{{memberList.errorText}}</div>
                                        </td>
                                        <td>
                                            <select class="isReadOnly" v-model="memberList.gender" disabled="true">
                                                <option label="女" value="女">女</option>
                                                <option label="男" value="男"></option>
                                            </select>
                                        </td>
                                        <td><input class="isReadOnly" type="text" v-model="memberList.companyName" disabled="true" ></td>
                                        <td>
                                            <!-- <select v-model="memberList.position" :disabled="inhibiting">
                                                <option v-for="post in positionAll" :value="post.id" :key="post.id">{{ post.positionName }}</option>
                                            </select> -->
                                            <select class="isReadOnly" v-model="memberList.position" disabled="true">
                                                <option class='form-default' value="0" disabled selected hidden></option>
                                                <option v-for="post in positionAll" v-bind:value="post.id" :key="post.id">{{ post.positionName }}</option>
                                            </select>
                                        </td>
                                        <td @click="clickinformatin(index,cindex)"><img src="../../static/image/clear.png"></td>
                                    </tr>
                                </tbody>
                            </table>
                                
                        </div>
                        
                    </div>

                </div>
            </div>



        </div>               
    </div>
</template>


<script>
  export default {
    data() {

        return {
            // 源索引
            startExchangeIndex: '',
            // 目标索引
            endExchangeIndex: '',
            // 课程名称
            courseName:'', 
            // 课程开始日期
            sdate:'',
            // 课程开始时间
            stime:'',
            // 课程结束日期
            edate:'',
            // 课程结束时间
            etime:'',
            // 课程结束日期和时间 
            endTime:'',
            // 自动运行是否被选中
            checked:'',
            // 是否自动运行 0 不自动运行 1自动运行
            autoRun: 0,
            // 自动运行时间间隔
            autoRunTime: "",            
            // sdate:'',
            // stime:'',
            // checked:'',
            boxchooseType:'1',
            // oncedata:'',
            // oncetime:'',
            // seconddata:'',
            // secondtime:'',
            // thirddata:'',
            // thirdtime:'',
            // fourdata:'',
            // fourtime:'',
            isShow: false,
            isA:true,
            isB:true,
             //添加学员显示（）
            isAdd:false,
            // 编辑或保存按钮显示/隐藏
            editOrSaveBtnShow: true,
            //更换组别/保存更换
            changeBtn:true,


            //自动运行的错误提示
            // startDateErr:false,
            // startTimeErr:false,
            // endDateErr:false,
            // endTimeErr:false,
            // apsDateErr:false,
            // apsTimeErr:false,     
            // apeDateErr:false,
            // apeTimeErr:false,  
            // autoRunTimeErr:false,
            roundDateErr:false,
            roundTimeErr:false,  

             // 自动运行显示
            runningshow:false,
            autoRunTime:'',
            courseRoundModels:[],

            //队伍报错
            errorinputtext:false,
            //队伍列表
            compileType:'1',

            memberAll:[
                {
                    teamMembersInfoList:[]
                },                
            ],
            positionAll:[] //职位


        };
    },
    computed:{
        "allInputDisable":function(){
            if(this.boxchooseType==1){
                return true
            }
            return false
        },
        // "inhibiting":function(){
        //     if(this.compileType==1){
        //         return true
        //     }
        //     return false
        // }
       

    },
    methods:{
        onDragstart (event) {
            if (this.editOrSaveBtnShow) {
                // event.target 都返回源元素
                this.startExchangeIndex = event.target.getAttribute('data-id')
                console.log('拖拽开始')
            }
            
        },
        onDragend (event) {
            if (this.editOrSaveBtnShow) {
                // event.target 都返回源元素
                // console.log('下标' + this.startExchangeIndex + ' 和 ' + this.endExchangeIndex + '进行替换')
                
                let startTeamIndex = parseInt(this.startExchangeIndex.split('-')[0])
                let startMemberIndex = parseInt(this.startExchangeIndex.split('-')[1])
                let endTeamIndex = parseInt(this.endExchangeIndex.split('-')[0])
                let endMemberIndex = parseInt(this.endExchangeIndex.split('-')[1])

                let _name = this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].name
                let _mobile = this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].mobile
                let _gender = this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].gender
                let _companyName = this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].companyName
                let _position = this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].position

                this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].name = this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].name
                this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].mobile = this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].mobile
                this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].gender = this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].gender
                this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].companyName = this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].companyName
                this.memberAll[endTeamIndex].teamMembersInfoList[endMemberIndex].position = this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].position

                this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].name = _name
                this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].mobile = _mobile
                this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].gender = _gender
                this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].companyName = _companyName
                this.memberAll[startTeamIndex].teamMembersInfoList[startMemberIndex].position = _position

                console.log('拖拽结束')
            }
        },
        onDrop (event) {
            if (this.editOrSaveBtnShow) {
                // event.target 都返回目标元素
                if (event.target.className == 'member') {
                    this.endExchangeIndex = event.target.getAttribute('data-id')
                } else {
                    if (event.target.nodeName === 'TD') {
                        this.endExchangeIndex = event.target.parentElement.getAttribute('data-id')
                    } else {
                        this.endExchangeIndex = event.target.parentElement.parentElement.getAttribute('data-id')
                    }
                }
            }
        },
        onDragover(event){
            // 阻止元素的默认行为，不然ondrop不管用
            event.preventDefault();
        },

        //课程详情
        boxchoose:function(type){
            this.isA=!this.isA
            switch(type){
                case 1:
                this.boxchooseType=2;
                break;
                case 2:


                //自动运行的checkbox
                let autoRunnum ;
                if(this.runningshow == false){
                    // this.runningshow = false
                    autoRunnum = 0
                }else{
                    autoRunnum = 1
                    // this.runningshow = true
                };
                
                let times = [];
                for (const key in this.courseRoundModels) {
                    if (this.courseRoundModels.hasOwnProperty(key)) {
                        const element = this.courseRoundModels[key];
                        let data = {
                            id: element.id,
                            courseId:element.courseId,
                            startTime: element.starDate + ' ' + element.startTime,
                            roundNum: element.roundNum,
                            createTime: ''
                        }
                        times.push(data)
                    }
                }
  
                let data={
                    id:this.$route.params.id,
                    courseName:this.courseName,
                    startTime:this.sdate +' '+ this.stime,
                    endTime:this.edate +' '+this.etime,
                    // applyStartTime:this.apsdate +' '+this.apstime,
                    // applyEndTime:this.apedate +' '+this.apetime,
                    // courseApplyCode:this.courseApplyCode,
                    courseRoundModelList:times,
                    autoRun:autoRunnum,
                    // autoRunTime:this.autoRunTime,  //因为   autoRunTime传来的数值为null
                    autoRunTime:'', //暂时数值
                    roundNumber:'',  
                    joinUrl:'',                   
                   
                    roundNumber:"",
                }
                this.$http.editInvitecourseDetails(data,(res)=>{
                    console.log(res)
                },(errorRes)=>{
                    console.log(errorRes)
                });

                this.boxchooseType=1;
                break;
            }
            this.flag=false
        // this.isReadOnly = true;
        },

        // 课程详情显示隐藏
        toggle:function(){
            this.isShow = !this.isShow;
        },

       
        // 获取课程详情接口
        getCourseDetails:function(){
            let data = {
                id:this.$route.params.id
            }
            // this.$http.generalCourseDetails(data,(res)=>{
            //     this.courseName = res.data.courseName; //课程名称
            //     this.sdate = res.data.startTime.split(" ")[0]; //课程开始日期
            //     this.stime = res.data.startTime.split(" ")[1]; //课程开始时间
            //     this.edate = res.data.endTime.split(" ")[0];   //课程结束日期
            //     this.etime = res.data.endTime.split(" ")[1];  //课程结束时间
            //     console.log(res)
            // },(errorRes)=>{
            //     console.log(errorRes)
            // })

            
            this.$http.generalCourseDetails(data,(res)=>{
                this.courseName = res.data.courseName; //课程名称
                this.sdate = res.data.startTime.split(" ")[0]; //课程开始日期
                this.stime = res.data.startTime.split(" ")[1]; //课程开始时间
                this.edate = res.data.endTime.split(" ")[0];   //课程结束日期
                this.etime = res.data.endTime.split(" ")[1];  //课程结束时间
                this.autoRunTime = res.data.createTime; //自动运行时间

                console.log(res.data.autoRun)
                //自动运行的checkbox
                if(res.data.autoRun == 0){
                    this.runningshow = false
                }else{
                    this.runningshow = true
                };
                // console.log(this.runningshow)
                this.autoRunTime = res.data.autoRunTime;
                // console.log(res.data.autoRunTime);
                //console.log(res.data.courseRoundModelList)
                this.courseRoundModels = res.data.courseRoundModelList;
                let tmp = res.data.courseRoundModelList
                console.log(tmp);
                for (const key in tmp) {
                    if (tmp.hasOwnProperty(key)) {
                        // const element = tmp[key];
                        this.courseRoundModels[key].roundsdate = tmp[key].startTime.split(' ')[0]
                        this.courseRoundModels[key].roundsetime = tmp[key].startTime.split(' ')[1]
                    }
                }
                console.log(res)
            },(errorRes)=>{
                close.log(errorRes)
            })
        },

        //一般课程编辑
        editGeneral:function(){

        },
        //获取职位        
        getposit:function(){
            this.$http.getPosition(null,(res)=>{
                this.positionAll = res.data
                console.log(res)
            },(errorRes)=>{
                console.log(errorRes)
            })
        },

        teamnumber:function(){
            // 根据队伍数生成队伍 默认6组
            let teamsNumber = 6;
            let data = {};
            this.memberAll = []; // 初始化
            this.itemNum = 65; // 初始化
            for (let index = 0; index < teamsNumber; index++) {
                data = {
                    teamName:"队伍"+String.fromCharCode(this.itemNum),
                    teamMembersInfoList:[]
                };
                for (let j = 0;j < 10; j++) {
                    let data2 = {
                        // studentNum: '学员'+(j+1),
                        name: '',
                        mobile: '',
                        gender: '',
                        companyName:'',
                        position:0
                    }
                    data.teamMembersInfoList.push(data2)
                }
                this.memberAll.push(data)
                this.itemNum++
            }
        },

        //点击删除 清空信息
        clickinformatin:function(teamIndex,memberIndex){
            console.log(teamIndex, memberIndex)
            this.memberAll[teamIndex].teamMembersInfoList[memberIndex].name = '';
            this.memberAll[teamIndex].teamMembersInfoList[memberIndex].mobile = '';
            this.memberAll[teamIndex].teamMembersInfoList[memberIndex].gender = '';
            this.memberAll[teamIndex].teamMembersInfoList[memberIndex].companyName = '';
            this.memberAll[teamIndex].teamMembersInfoList[memberIndex].position = '';

            let inputParent = document.getElementsByClassName('pageMember')
            let inputParentTr = inputParent[teamIndex].getElementsByClassName('memberTr')
            let isReadOnlyInput = inputParentTr[memberIndex].getElementsByClassName('isReadOnly');

            for (const key in isReadOnlyInput) {
                const element = isReadOnlyInput[key]
                if (element.nodeType == 1) {
                    element.removeAttribute('disabled')
                    element.classList.remove('border-none')
                }
            }
        },

        //手机号失去焦点
        blurValidator:function(mobile,memberAll,event){

            let count = 0;
            let nextTarget = event.target.nextElementSibling;

            for(let i in memberAll){
                for (let j in memberAll[i].teamMembersInfoList){
                    // 判断手机号码是否重复，重复则count+1
                    if (memberAll[i].teamMembersInfoList[j].mobile == mobile && mobile != '') {
                        count++;
                    } 
                }
            }


            let reg = /^[1][3,4,5,7,8][0-9]{9}$/; //格式正则表达式


            // 基本验证
            if (mobile != '') {
                if(!reg.test(mobile)){
                    nextTarget.innerHTML = '手机号码格式错误'
                    nextTarget.style.display= 'block'
                } else if(count>=2){
                    nextTarget.innerHTML = '手机号码重复'
                    nextTarget.style.display= 'block'
                } else {
                    nextTarget.innerHTML = ''
                    nextTarget.style.background= 'none'
                }
            } else {
                nextTarget.innerHTML = '' // 这里是为了如果写了错误的手机号码，下面会有提示，删除手机号码还会存在，就在这里清空
                nextTarget.style.background= 'none' // 同上
            }
        },

        //队伍列表展示接口
        teamlistShow:function(){
            let data={
                id:1
                //id: this.$route.params.id
            }
            this.$http.lookMembers(data,(res)=>{
                console.log(res)
                this.memberAll = res.data           
                console.log(res)
            },(errorRes)=>{
                console.log(errorRes);
            })
        },

        // 学员查看展示接口
        teamlistShow:function(){
            //debugger
            let data={
                //id: 1 //暂用（审查数据）
                id: this.$route.params.id
            }
            this.$http.lookMembers(data,(res)=>{
                console.log(res)
                //this.memberAll = res.data
                for (const i in res.data) {
                    const teamObj = res.data[i]
                    this.memberAll[i].teamName = teamObj.teamName;
                    this.memberAll[i].teamId = teamObj.teamId;
                    this.memberAll[i].joinUrl = "";
                   
                    for (const j in teamObj.teamMembersInfoList) {
                        const memberObj = teamObj.teamMembersInfoList[j]
                        this.memberAll[i].teamMembersInfoList[j].name = memberObj.name;
                        this.memberAll[i].teamMembersInfoList[j].mobile = memberObj.mobile;
                        this.memberAll[i].teamMembersInfoList[j].gender = memberObj.gender;
                        this.memberAll[i].teamMembersInfoList[j].companyName = memberObj.companyName;
                        this.memberAll[i].teamMembersInfoList[j].position = memberObj.position; 
                        this.memberAll[i].teamMembersInfoList[j].age = memberObj.age;
                        this.memberAll[i].teamMembersInfoList[j].id = memberObj.id;
                        this.memberAll[i].teamMembersInfoList[j].positionName = memberObj.positionName;                       
                    }
                }
                console.log(res)
            },(errorRes)=>{
                console.log(errorRes);
            })
        },


        //更换组别/保存更换
        editchangeBtn:function(){
            this.changeBtn = !this.changeBtn
        },


        // 编辑或保存处理
        editOrSaveHandler(){
            this.editOrSaveBtnShow = !this.editOrSaveBtnShow
            // 点击编辑按钮（保存按钮显示）
            if (this.editOrSaveBtnShow === false) {
                this.isB = false
                this.isAdd = true
                let inputParent = document.getElementsByClassName('pageMember')
                for (const teamIndex in this.memberAll) {
                    const teamObj = this.memberAll[teamIndex]
                    let inputParentTr = inputParent[teamIndex].getElementsByClassName('memberTr')
                    for (const memberIndex in teamObj.teamMembersInfoList) {
                        const memberObj = teamObj.teamMembersInfoList[memberIndex]
                        if (memberObj.name == '' && memberObj.mobile == '' && memberObj.gender == '' && memberObj.companyName == '' && memberObj.position == '') {
                            let isReadOnlyInput = inputParentTr[memberIndex].getElementsByClassName('isReadOnly');
                            for (const key in isReadOnlyInput) {
                                const element = isReadOnlyInput[key]
                                if (element.nodeType == 1) {
                                    element.removeAttribute('disabled')
                                }
                            }
                        } else {
                            let isReadOnlyInput = inputParentTr[memberIndex].getElementsByClassName('isReadOnly');
                            for (const key in isReadOnlyInput) {
                                const element = isReadOnlyInput[key]
                                if (element.nodeType == 1) {
                                    element.setAttribute('disabled', true)
                                    element.classList.add('border-none')
                                }
                            }
                        }
                    }
                }
            } else {
               //点击保存按钮
                this.isB = true
                this.isAdd = false                
                let isReadOnlyInput = document.getElementsByClassName('isReadOnly');
                //禁止编辑               
                for (const key in isReadOnlyInput) {
                    const element = isReadOnlyInput[key]
                    if (element.nodeType == 1) {
                        element.setAttribute('disabled', true)
                    }
                }

                /******** 手机格式验证 start ********/
                let reg = /^[1][3,4,5,7,8][0-9]{9}$/; //格式正则表达式
                let count = 0;
                for(let i in this.memberAll){
                    for (let j in this.memberAll[i].teamMembersInfoList){
                        if (this.memberAll[i].teamMembersInfoList[j].mobile != '') {
                            // 验证手机格式
                            if (!reg.test(this.memberAll[i].teamMembersInfoList[j].mobile)) {
                                this.memberAll[i].teamMembersInfoList[j].errorinputtext=true
                                this.memberAll[i].teamMembersInfoList[j].errorText="号码格式错误" 
                                let data = {
                                    mobile:this.memberAll[i].teamMembersInfoList[j].mobile
                                    // teamIndex:i,
                                    // memberIndex:j,
                                    // errorText:'手机号码格式错误'
                                };
                                positionArr.push(data)
                            }
                            else{
                                this.memberAll[i].teamMembersInfoList[j].errorinputtext=false
                            }

                            
                            
                        }
                    }
                }
                /******** 手机格式验证 end ********/

                                
                //判断非空传回 接口             
                let teams = []
                let data={
                    courseId:this.$route.params.id,
                    adminTeamMembersList:[],
                }
                for(const i in this.memberAll){
                    const teamobj = this.memberAll[i]
                        let data2 = {
                            teamId:teamobj.teamId,
                            teamName:teamobj.teamName,
                            joinUrl:teamobj.joinUrl,
                            teamMembersInfoList:[]
                        }
                    for(const j in teamobj.teamMembersInfoList){
                        const memberobj =  teamobj.teamMembersInfoList[j]
                        if(memberobj.mobile =='' || memberobj.name =='' || memberobj.gender ==''|| memberobj.position =='' || memberobj.companyName ==''){                      
                            break
                        }else{
                             let data3 = {
                                id:memberobj.id,
                                mobile:memberobj.mobile,
                                name:memberobj.name,
                                gender:memberobj.gender,
                                position:memberobj.position,
                                positionName:memberobj.positionName,
                                age:memberobj.age,
                                companyName:memberobj.companyName,
                            }
                            data2.teamMembersInfoList.push(data3)
                        }
                    }    
                    if (data2.teamMembersInfoList.length > 0) {
                        data.adminTeamMembersList.push(data2)   
                    }                 
                }
                                
                console.log(this.$route.params.id)
                this.$http.editTeam(data,(res)=>{
                    console.log(res)
                },(errorRes)=>{
                    console.log(errorRes)
                });  
            }
        },


    },

    mounted(){
        this.getCourseDetails();//获取课程详情
        //this.editGeneral(); //课程详情编辑接口
        this.teamnumber(); //队伍列表数        
        this.teamlistShow(); //队伍列表展示接口
        this.getposit();  //获取职位 接口
    }


  };
</script>



